﻿Shader "Custom/GrayScale" {
	Properties {
		_MainTex ("Base (RGB)", 2D) = "white" {}
	}
	
	CGINCLUDE
	#include "UnityCg.cginc"
	
	sampler2D _MainTex;
	
	struct v2f{
		float4 pos:POSITION;
		float2 uv:TEXCOORD;
	};
	
	v2f vert(appdata_base i){
		v2f o;
		o.pos = mul(UNITY_MATRIX_MVP,i.vertex);
		o.uv = i.texcoord;
		return o;
	}
	
	float4 frag(v2f i):COLOR{
		float4 c = tex2D(_MainTex,i.uv);
		// c.rgb = (c.r+c.b+c.g)/3;
		c.rgb = c.r * 0.21 + c.g * 0.72 + c.b * 0.07; // float3(0.21,0.72,0.07);
		return c;
	}
	
	ENDCG
	
	SubShader {
		Tags { "RenderType"="Opaque" }
		LOD 200

		Pass{
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			ENDCG
		}
	} 
	FallBack "Diffuse"
}
